Returns a selected value from a list of arguments.
引数のリストの中から、指定された値を返します。
Choose (Index, Selection1[, Selection2, ... [,Selection_n]])
Choose (Index, Selection1[, Selection2, ...[,Selection_n]])
Index: A numeric expression that specifies the value to return.
Index: 返す値を指定するための数値表式。
Selection1: Any expression that contains one of the possible choices.
Selection1: 戻り値の候補となる任意の値。
The Choose function returns a value from the list of expressions based on the index value. If Index = 1, the function returns the first expression in the list, if index i= 2, it returns the second expression, and so on.
Choose 関数は、与えられた値のリストの中から、インデックス値の指定するものを返します。ここでは、インデックス値が 1 であればリスト中の 1 番目の値を返し、インデックス値が 2 であればリスト中の 2 番目の値を返す、という処理が行われます。
If the index value is less than 1 or greater than the number of expressions listed, the function returns a Null value.
インデックス値が 1 より小さいか、リストの要素数よりも大きい場合、関数の戻り値は Null 値が返されます。
The following example uses the Choose function to select a string from several strings that form a menu:
下記の例では、Choose 関数を使って、メニューを構成する複数の文字列の中から、特定の文字列を取り出しています。
Sub ExampleChoose
Sub ExampleChoose
Dim sReturn As String
Dim sReturn As String
sReturn = ChooseMenu(2)
sReturn = ChooseMenu(2)
Print sReturn
Print sReturn
end sub
end sub
Function ChooseMenu(Index As Integer)
Function ChooseMenu(Index As Integer)
ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")
ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")
End Function
End Function